local qingfeng = fk.CreateSkill {
  name = "lingling__qingfeng",
  tags = { Skill.Combo },
}

Fk:loadTranslationTable{
  ["lingling__qingfeng"] = "青锋",
  [":lingling__qingfeng"] = "连招技（武器牌+【杀】），弃置目标两张牌。",

  ["#lingling__qingfeng-discard"] = "青锋：弃置 %dest 两张牌",
}

qingfeng:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(qingfeng.name) and
      data.extra_data and data.extra_data.combo_skill and data.extra_data.combo_skill[qingfeng.name] and
      not data.to:isNude()
  end,
  on_cost = function (self, event, target, player, data)
    event:setCostData(self, {tos = {data.to}})
    return true
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local cards = room:askToChooseCards(player, {
      target = data.to,
      min = 2,
      max = 2,
      flag = "he",
      skill_name = qingfeng.name,
      prompt = "#lingling__qingfeng-discard::"..data.to.id,
    })
    room:throwCard(cards, qingfeng.name, data.to, player)
  end,
})

qingfeng:addEffect(fk.AfterCardUseDeclared, {
  can_refresh = function (self, event, target, player, data)
    return target == player and player:hasSkill(qingfeng.name, true) and data.card.trueName == "slash"
  end,
  on_refresh = function (self, event, target, player, data)
    local room = player.room
    local use_events = room.logic:getEventsByRule(GameEvent.UseCard, 2, function (e)
      return e.data.from == player
    end, Player.HistoryGame)
    if #use_events == 2 and use_events[2].data.card.sub_type == Card.SubtypeWeapon then
      data.extra_data = data.extra_data or {}
      data.extra_data.combo_skill = data.extra_data.combo_skill or {}
      data.extra_data.combo_skill[qingfeng.name] = true
    end
  end,
})

return qingfeng
